using System.Collections.Generic;
using UnityEngine;

[System.Serializable]
public class AnimalEntry
{
    public string name;
    public string info;
    public Sprite spriteAnimal;
    public Sprite spriteBackground;
    public float stampSeed;
}


public class ZooNotebookManager : MonoBehaviour
{
    public static ZooNotebookManager Instance;

    public List<AnimalEntry> collectedAnimals = new();

    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
            DontDestroyOnLoad(gameObject);
        }
        else Destroy(gameObject);
    }

    public void AddAnimal(string name, string info, Sprite animalSprite, Sprite bgSprite)
    {
        // Check duplicates
        var found = collectedAnimals.Find(a =>
            a.name.ToLower() == name.ToLower());

        if (found != null) return;

        collectedAnimals.Add(new AnimalEntry
        {
            name = name,
            info = info,
            spriteAnimal = animalSprite,
            spriteBackground = bgSprite,
            stampSeed = Random.value
        });

        Debug.Log($"[ZooNotebook] Saved: {name}");
    }


    public AnimalEntry GetAnimal(string name)
    {
        return collectedAnimals.Find(a =>
            a.name.ToLower() == name.ToLower());
    }
}